package cn.lcc.utils.demo.client;

import cn.lcc.utils.demo.jt808.WatchHeader;
import hy.iot.core.support.IotFieldConfig;
import hy.iot.core.support.IotFieldTranseSupport;

public class Demo {

    /**
     * hex -> 协议头文件 解析 -> 解析body -> 调用响应处理
     * @param args
     */
    public static void main(String[] args) {
    String shex = "33472A393632303435393434302A303039312A55445F44454D4F2C3031303732342C3031303530382C412C33322E3933383336332C4E2C3131352E383639373638332C452C302E33352C3230322E332C302E302C31322C3130302C35342C302C302C30303030303030302C312C302C3436302C302C32323234392C3235323236353535322C3138382C312C2C39433A37463A38313A37333A41353A38422C2D39332C302E30";
        // 初始化
        IotFieldTranseSupport support = new IotFieldTranseSupport(new IotFieldConfig(
                WatchHeader.class,"cn.lcc.utils.demo.jt808",null,"cn.lcc.utils.demo.client","watch"
        ));
        // TODO 多版本适配  父类转义
        support.mergeFrom(shex,null);


        // 协议功能文件
//        FieldScanClass fieldScanClass = new FieldScanClass("hy.iot.core.jt808",WatchHeader.class);
//        Map<String, Class> fc = fieldScanClass.getFidldSchemaMap();
//        fc.forEach((k,v)->{
//            System.out.println(k+"  -> "+ v.getDeclaredFields()[0].getName());
//        });
//        System.out.println(fc.size());
//
//        throw new IotFieldException(FieldFailCodes.IOT_FAIL_INIT);

        // 解析器
//        ParserSupport support = new ParserSupport("hy.iot.core.schema","");
//        Map<String, Handler> sd = support.getSchemas();
//        try {
//           Object d = sd.get("Hex4ToTenSchema").invoke("028a");
//        } catch (Exception e) {
//            throw new RuntimeException(e);
//        }

    }
}
